package com.ihd.ihardware.view.tzc.me.viewmodel;

import android.app.Application;
import android.arch.lifecycle.AndroidViewModel;
import android.support.annotation.NonNull;

import com.ihd.ihardware.view.tzc.me.model.MeRepository;

import java.io.File;


public class InfoViewModel extends AndroidViewModel{
    private MeRepository mMeRepository;

    public InfoViewModel(@NonNull Application application) {
        super(application);
    }

    public void updateInfo(String avatar, String nickName, int sex, String birthday, String height, String weight) {
        if (mMeRepository == null)
            mMeRepository = new MeRepository();
        mMeRepository.updateInfo(avatar, nickName, sex, birthday, height, weight);
    }

    public void updateHead(File f) {
        if (mMeRepository == null)
            mMeRepository = new MeRepository();
        mMeRepository.updateHead(f);
    }

    @Override
    protected void onCleared() {
        super.onCleared();
        if(null != mMeRepository) {
            mMeRepository.onDestroy();
            mMeRepository = null;
        }
    }
}
